#coding:utf-8
#!/usr/bin/env python
icone = 'images/icone.png'
tuxlash = 'images/tuxlash.png'
fundo = 'musicas/tapapai.ogg'
nota1 = 'images/nota1.png'
nota2 = 'images/nota2.png'
import pygame
from pygame.locals import *

try:
    fonte = "NIGHTMARE_HERO_NORMAL"
except:
    fonte = 'tahoma' 

pygame.init()
ecra = pygame.display.set_mode((800,640))
icone = pygame.image.load(icone).convert_alpha()
tuxlash = pygame.image.load(tuxlash).convert_alpha()
nota1 = pygame.image.load(nota1).convert_alpha()
nota2 = pygame.image.load(nota2).convert_alpha()
sizesair, sizein, sizeop = 30, 30, 30
pygame.mouse.set_visible(False)
mousepos=450
cor1, cor2, cor3 = (0,0,0), (0,0,0), (0,0,0)
posnota, posnota1, posnota2 = 70, 200, 30

#musica de fundo
pygame.mixer.init()
pygame.mixer.music.load(fundo)
pygame.mixer.music.play()

while True:  
    for event in pygame.event.get():     
        if event.type==QUIT or pygame.key.get_pressed()[K_ESCAPE]:
            exit()
    #treme notas musicais
    if posnota==70:
        posnota+=1
        posnota1+=1
        posnota2+=1
    else:
        posnota-=1
        posnota1-=1
        posnota2-=1        
            
    ecra.fill((205,201,201))    
    ecra.blit(tuxlash,(0,300))
    ecra.blit(nota2,(posnota,250))
    ecra.blit(nota1,(posnota1,300))
    ecra.blit(nota2,(posnota1,380))
    ecra.blit(nota1,(posnota2,220))    
    
    Logo = ecra.blit(pygame.font.SysFont(fonte, 170).render("Tux Hero" ,True, (0,0,0)), (100,0))
    
    #Opções
    Iniciar = ecra.blit(pygame.font.SysFont("tahoma", sizein).render("Jogo Rapido " ,True, cor1), (mousepos, 300))
    options = ecra.blit(pygame.font.SysFont("tahoma", sizeop).render("Creditos " ,True, cor2), (mousepos, 350))
    sair = ecra.blit(pygame.font.SysFont("tahoma", sizesair).render("Sair" ,True, cor3), (mousepos, 400))
    
    tecla = pygame.key.get_pressed()
    
    #Aumentar o tamanho e mudar a cor das opções ao passar o mouse
    x,y = pygame.mouse.get_pos()    
    x-= icone.get_width()/2
    y-= icone.get_height()/2

    if (380<x<600) and (400<y<500):
        sizesair=40
        cor3=(255,0,0)
    else:
        sizesair = 30
        cor3 = (0,0,0)
    
    if (380<x<600) and (300<y<400):
        sizeop=40
        cor2=(255,0,0)
    else:
        sizeop = 30
        cor2 = (0,0,0)
        
    if (380<x<600) and (200<y<300):
        sizein=40
        cor1=(255,0,0)
    else:
        sizein = 30
        cor1 = (0,0,0)  
    ecra.blit(icone, (x,y))
    
    clique = pygame.mouse.get_pressed()    
    if clique[0]:
        if (300<y<400):
            execfile('creditos.py')
        elif (200<y<300):
            execfile('selecaomusica.py')
        elif (400<y<500):
            ecra.fill((205,201,201))
            Logo = ecra.blit(pygame.font.SysFont(fonte, 170).render("Tux bye" ,True, (0,0,0)), (200,170))
            pygame.display.flip()
            pygame.time.wait(300)            
            quit()
            
    pygame.display.flip()